class Solution:
    def getHint(self, secret: str, guess: str) -> str:
        mid_dic = {str(i): 0 for i in range(10)}
        mid_set = set()
        count_a, count_b = 0, 0
        length = len(secret)
        for index in range(length):
            if secret[index] == guess[index]:
                count_a += 1
                mid_set.add(index)
            else:
                mid_dic[secret[index]] += 1
        for index in range(length):
            if index not in mid_set and mid_dic[guess[index]] > 0:
                count_b += 1
                mid_dic[guess[index]] -= 1
        return str(count_a) + "A" + str(count_b) + "B"


a = Solution()
print(a.getHint(secret="1807", guess="7810"))
print(a.getHint(secret = "1123", guess = "0111"))
